package cn.yy.cloudpay.view;

import cn.yy.cloudpay.R;
import android.content.Context;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class ToastUtil {
	
	public static final int SUCCESS = 0x001;
	public static final int FAIL = 0x002;
	public static final int WARNING = 0x003;

	public ToastUtil() {
	}
	
	public static void showToast(Context context, String msg, int type ) {
		View view = LayoutInflater.from(context).inflate(R.layout.toast_layout, null);
		TextView tvMsg = (TextView) view.findViewById(R.id.tv_toast_msg);
		ImageView ivImg = (ImageView) view.findViewById(R.id.iv_toast_img);
		switch(type) {
			case SUCCESS :
				ivImg.setImageResource(R.drawable.toast_success);
				break;
			case FAIL :
				ivImg.setImageResource(R.drawable.toast_error);
				break;
			case WARNING :
				ivImg.setImageResource(R.drawable.toast_warning);
				break;
			default :
				break;
		}
		tvMsg.setText(msg);
		Toast toast = new Toast(context);
		toast.setView(view);
		toast.setGravity(Gravity.BOTTOM, 0, 0);
		toast.setDuration(Toast.LENGTH_LONG);
		toast.show();
	}
}
